package com.epoint.mobileoa.ui.wsgw.bizlogic;

import java.io.File;

import android.content.Context;
import android.util.Base64;

import com.epoint.mobileoa.R;
import com.epoint.mobileoa.tools.IOHelp;
import com.epoint.mobileoa.ui.init.InitView;

/**
 * @author liyc
 * @time 2012-12-18 下午4:05:39
 * @annotation 
 */
public class AttachDeal {
	public static void saveAndOpenFile(Context con,String AttContent_64Code,String guid,String AttFileName)
	{
		byte[] b = Base64.decode(AttContent_64Code, Base64.DEFAULT);
		String folder = "/"+InitView.MobileOaMainStoreFolder+"/"+con.getString(R.string.sdforder)+"/attachdownload/"+guid;
		IOHelp.FoldCreate(folder);
		String path = folder+"/"+AttFileName;
		IOHelp.saveFile(b, path); 
		File f = new File(path);
		if(f.exists()&&f.length()>0)
		{
			IOHelp.doOpenFile(con, path);
		}
	}
	
	public static boolean openFile(Context con,String guid,String AttFileName)
	{
		String folder = "/"+InitView.MobileOaMainStoreFolder+"/"+con.getString(R.string.sdforder)+"/attachdownload/"+guid;
		String path = folder+"/"+AttFileName;
		File f = new File(path);
		if(f.exists()&&f.length()>0)
		{
			IOHelp.doOpenFile(con, path);
			return true;
		}
		return false;
	}
}
